package com.zb.system.controller;


import com.zb.entity.SelectVo;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.ZjSystemLoginLogService;
import com.zb.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 系统登录日志表 前端控制器
 * </p>
 *
 * @author WEN
 * @since 2024-03-07
 */
@Api(tags = "系统登录日志类接口")
@RestController
@RequestMapping("/system/login/log")
public class ZjSystemLoginLogController {
    @Resource
    private ZjSystemLoginLogService systemLoginLogService;

    @ApiOperation("获取登录日志列表")
    @PostMapping("/getList")
    public Result getList(HttpServletRequest request, @RequestBody @ApiParam(value = "搜索关键词：登录账号/登录用户名") SelectVo search) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取登录日志列表成功").data(systemLoginLogService.getList(custAccId, search));
    }

    @ApiOperation("根据账号ID获取登录日志")
    @PostMapping("/getLoginLog/{accountId}")
    public Result getLoginLog(HttpServletRequest request, @PathVariable @ApiParam(value = "账号ID", required = true) Long accountId,
                              @RequestBody PageUtil pageUtil) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取登录日志成功").data(systemLoginLogService.getLoginLog(custAccId, accountId, pageUtil));
    }


}
